package com.atguigu.h_areacode;

public class Test {
    public static void main(String[] args) {
        //创建子类对象
        Zi zi = new Zi(); //创建了1个真实Zi类对象 和一个虚拟Fu类对象[super]
    }
}

class Fu{
    static{
        System.out.println("父类的静态代码块执行了 ! ");//1
    }

    {
        System.out.println("父类的构造代码块执行了 ! ");//3
    }
    public Fu() {
        super();
        System.out.println("父类构造执行了!");//4
    }

    public Fu(String name){
        this();
        System.out.println("父类的有参构造执行了!" + name);//5
    }
}
class Zi extends Fu{
    static{
        System.out.println("子类的静态代码块执行了 ! ");//2
    }

    {
        System.out.println("子类的构造代码块执行了 ! ");//6
    }
    public Zi() {
        //调用本类的有参构造
        this(18);
        System.out.println("子类构造执行了!");//8
    }

    public Zi(int age) {
        super("张三");
        System.out.println("子类的有参构造执行了!" + age);//7
    }
}